<div class="page-header">
  <strong class="page-header-title">版本</strong>
  <button class="btn btn-primary btn-sm pull-right" style="margin-top: -6px;" ng-click="addVersion()">新增</button>
  <div class="checkbox pull-right" style="margin-top: 0;margin-right: 10px">
    <label>
      <input type="checkbox" value="" ng-model="status">
      查看已关闭版本
    </label>
  </div>
</div>
<div id="version-container" class="version-container">
  <table class="table table-hover table-bordered table-project" ng-repeat="project in versionList">
    <thead>
      <tr>
        <th class="col-xs-3"><span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span>&nbsp;&nbsp;{{project.name}}</th>
        <th class="col-xs-3">时间周期</th>
        <th class="col-xs-3">休息日</th>
        <th class="col-xs-3 text-center">操作</th>
      </tr>
    </thead>
    <tbody>
      <tr ng-repeat="version in project.versions" ng-if="version.status == status">
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{version.name}}</td>
        <td>{{version.start_time * 1000 | date:"yyyy/MM/dd"}} - {{version.end_time * 1000 | date:"yyyy/MM/dd"}}</td>
        <td><span class="label label-primary" ng-repeat="date in version.relaxed_arr">{{date}}</span></td>
        <td class="text-center">
          <div class="btn-group btn-group-sm">
            <button class="btn btn-primary" ng-click="editVersion(version.id)">修改</button>
            <button class="btn btn-primary" ng-click="deleteVersion(version.id)">删除</button>
            <button class="btn btn-primary" ng-click="closeVersion(version.id)" ng-if="!version.status">关闭</button>
            <button class="btn btn-primary" ng-click="openVersion(version.id)" ng-if="version.status">开启</button>
          </div>
        </td>
      </tr>
    </tbody>
  </table>
</div>
<div id="version-form" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">{{action == '1' ? '新增' : '修改'}}版本</h4>
      </div>
      <div class="modal-body">
        <form class="form-horizontal" name="myForm">
          <div class="form-group">
            <label class="col-sm-2 control-label">版本名称 <span style="color: red;">*</span></label>
            <div class="col-sm-10">
              <input type="text" class="form-control" ng-model="versionData.name" required>
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label">所属项目 <span style="color: red;">*</span></label>
            <div class="col-sm-10">
              <select class="form-control" ng-model="versionData.project_id" required>
                <option value="{{project.id}}" ng-repeat="project in projectList">{{project.name}}</option>
              </select>
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label">开始时间 <span style="color: red;">*</span></label>
            <div class="col-sm-10">
              <input type="date" class="form-control" ng-model="versionData.start_time" required>
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label">结束时间 <span style="color: red;">*</span></label>
            <div class="col-sm-10">
              <input type="date" class="form-control" ng-model="versionData.end_time" required>
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label">休息日</label>
            <div class="col-sm-10">
              <input type="text" id="relax-date" class="form-control" style="width: 0;padding: 0;border: 0;display: inline-block;">
              <span class="label label-primary" ng-repeat="date in versionData.relaxed_arr">{{date}}&nbsp;<button type="button" class="close" aria-label="Close" ng-click="deleteDate($index)"><span aria-hidden="true">×</span></button></span>
            </div>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" ng-disabled="myForm.$invalid" ng-click="save()">保存</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->